<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="author" content="逯灿灿">
    <title>选项卡</title>
    <style>
    *{
            box-sizing: border-box;
    }
    body{
        margin: 0;
    }
    .container{
        width: 800px;
        margin: 100px auto;
    }
    .nav{
        width: 800px;
        height: 50px;
        background-color: #333;
    }
    ul{
        list-style: none;
    }
    .nav-list{
        
        display: flex;
        line-height: 50px;
        margin: 0;
        padding: 0 ;
    }
    .nav-list li{ 
        padding: 0 40px;
        color: white;
    }
    .message{
        
        position: relative;
    }
    .message ul{
        margin: 0;
        width: 800px;
        /* left: 260px; */
        border: 1px solid black;
        position: absolute;
        display: none; 
    }
    .message ul li{
        margin-left: 280px;
    }
   
    </style>
</head>

<body>
    <div class="container">
        <nav class="nav">
            <ul class="nav-list">
                <li>选项一</li>
                <li>选项二</li>
                <li>选项三</li>
            </ul>
        </nav>
        <div class="message">
            <ul class="message-one">
                <li>内容1</li>
                <li>内容2</li>
                <li>内容3</li>
            </ul>
            <ul class="message-two">
                <li>内容1</li>
                <li>内容2</li>
                <li>内容3</li>
                <li>内容4</li>
                <li>内容5</li>
            </ul>
            <ul class="message-three">
                <li>内容1</li>
                <li>内容2</li>
                <li>内容3</li>
            </ul>
        </div>
    </div>


    <script src="./js/jquery.js"></script>
</body>

</html>
<script>
    var List = $('.nav-list').children('li');
    var mess = $('.message').children('ul');

    var index = 0;
    List.hover(function(){
        $(this).css('background-color','red');
        var count = List.index(this);    
        mess.eq(count).css('display','block').siblings().css('display','none');
    },function(){
        $(this).css('background-color','#333');
        mess.css('display','none');
    });
</script>